<?php

include(BASEPATH . "../assets/lib/jp/jpgraph.php");
include(BASEPATH . "../assets/lib/jp/jpgraph_bar.php");




	
function Hbar_graph($x,$y, $name = "bar",$title="")
{
	
	// Size of graph
	$width=500;
	$height=200;
	 
	// Set the basic parameters of the graph
	$graph = new Graph($width,$height,'auto');
	$graph->SetScale('textlin');
	 
	// Rotate graph 90 degrees and set margin
	$graph->Set90AndMargin(100,20,50,20);
	 
	// Nice shadow
	$graph->SetShadow();
	 
	// Setup title
	$graph->title->Set($title);
	$graph->title->SetFont(FF_VERDANA,FS_BOLD,8);
	 
	// Setup X-axis
	$graph->xaxis->SetTickLabels($x);
	$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
	 
	// Some extra margin looks nicer
	$graph->xaxis->SetLabelMargin(10);
	 
	// Label align for X-axis
	$graph->xaxis->SetLabelAlign('right','center');
	 
	// Add some grace to y-axis so the bars doesn't go
	// all the way to the end of the plot area
	$graph->yaxis->scale->SetGrace(20);
	 
	// We don't want to display Y-axis
	//$graph->yaxis->Hide();
	 
	// Now create a bar pot
	$bplot = new BarPlot($y);
	$bplot->SetShadow();
	$bplot->SetFillColor('#91A200');
	
	 
	//You can change the width of the bars if you like
	//$bplot->SetWidth(0.5);
	 
	// We want to display the value of each bar at the top
	$bplot->value->Show();
	$bplot->value->SetFont(FF_ARIAL,FS_BOLD,12);
	$bplot->value->SetAlign('left','center');
	$bplot->value->SetColor('black','darkred');
	$bplot->value->SetFormat('%.1f mkr');
	
	// Add the bar to the graph
	$graph->Add($bplot);
	 
	// .. and stroke the graph
	$img = "chart_".$name.".jpg";
	$path = chart_path . $img;
	if(fopen($path, 'w'))
		unlink($path);
		
	$graph->Stroke($path);
	return $img;
}